草庐IT

在Git 中ping github.com超时Request timed out.

全部标签

go - 多路复用器去 :12: can't find import: "github.com/gorilla/context"`

我正在尝试安装我的Go测试包,但我一直收到此错误:D:\Developpement\golang\src\github.com\gorilla\mux\mux.go:12:找不到导入:“github.com/gorilla/context”这是我的代码:packagemainimport("github.com/gorilla/pat""net/http")funcmain(){mux:=pat.New()mux.Get("/user/:name/profile",http.HandlerFunc(profile))http.Handle("/",mux)log.Println("Li

mysql - 如何使用 github.com/go-sql-driver/mysql 指定服务器的端口号?

我正在为MySQL使用以下包http://godoc.org/github.com/go-sql-driver/mysql#MySQLDriver.Open我的代码是:import("bufio""database/sql"_"github.com/go-sql-driver/mysql")db,err:=sql.Open("mysql","me_id:username@tcp(db1.abc.com)/dataname?timeout=2s")但我收到错误消息error:dialtcp:missingportinaddressdb1.abc.com无论如何我可以指定没有任何端口号的服

go - HTTP 客户端,空闲超时

如何在GoHTTP客户端中设置空闲超时?空闲超时是指从HTTP客户端内部调用Conn接口(interface)的读/写方法时超时。当客户端下载文件并且在某些时刻由于达到读取超时而导致下载失败时,它会很有用。 最佳答案 您需要创建自己的net.Dialer,它返回一个net.Conn,它设置了适当的读写截止时间。Conn看起来像这样://Connwrapsanet.Conn,andsetsadeadlineforeveryread//andwriteoperation.typeConnstruct{net.ConnReadTimeou

go - 使用 code.google.com/p/google-api-go-client/youtube/v3 的 YouTube v3 api

尝试从我的channel获取上传列表,但出现错误“ChannelContentDetails没有上传字段或方法”apiCall:=youtube.Channels.List("contentDetails").Mine(true)response,err:=apiCall.Do()iferr!=nil{log.Fatalf("ErrormakingAPIcall:%v",err.Error())}fmt.Println(response.Items[0].ContentDetails.uploads) 最佳答案 response.I

go - smtp.Dial ("ASPMX.L.GOOGLE.COM:25") 连接错误;但是腻子连接有效

使用Go和smtp.Dial时,甚至net.Dial,我收到错误:dialtcp64.233.169.27:25:ConnectExtcp:Aconnectionattemptfailedbecausetheconnectedpartydidnotproperlyrespondafteraperiodoftime,orestablishedconnectionfailedbecauseconnectedhosthasfailedtorespond.来自这段代码:mxClient,err:=smtp.Dial("ASPMX.L.GOOGLE.COM:25")iferr!=nil{fmt.

具有不同超时的 Golang goroutine-safe http 客户端?

假设我有以下功能:funcSendRequest(c*Client,timeouttime.Duration){iftimeout>0{c.Timeout=timeout}else{c.Timeout=defaultTimeout}...}我想允许多个go-routines调用这个函数(共享同一个HTTP客户端),但是这样写显然不能保证goroutine的安全。(同时更改传入的客户端超时也很奇怪......)我不确定执行此操作的最佳方法是什么。我应该为不同的超时使用不同的客户端吗?我应该使用一些互斥量吗?或者一般来说,我如何共享具有不同超时的HTTP客户端?谢谢!

git - 如何在 git2go (libgit2) 中列出包含给定提交的分支?

给定一个特定的引用(在本例中是一个标签),你如何列出包含该提交的分支git2go?类似于gitbranch--contains. 最佳答案 这里的问题,从图的角度来看是“我怎么知道A是否是B的祖先?”(对于您想成为B的每个分支重复几次)。回答这个问题的唯一方法是从B开始沿着历史图走下去,然后检查是否找到A。您可以通过几种方式做到这一点,但最有效的通常是将问题简化为等同的“A是A和B的merge基础吗?”。您可以通过Repository.MergeBase()在git2go中询问这个问题。这将返回您提供的两个提交之间的最佳merge基

git - Gig2go : unpacking the sent packfile failed on the remote

我为此苦苦挣扎。我正在尝试使用以下代码将更改推送到存储库://Getremoteremote,err:=repo.Remotes.Lookup("origin")iferr!=nil{remote,err=repo.Remotes.Create("origin",repo.Path())iferr!=nil{returnerr}}//Getthebranchbranch,err:=repo.Branch()iferr!=nil{returnerr}//GetthenamebranchName,err:=branch.Name()iferr!=nil{returnerr}iferr:=r

走。在服务器程序中获取错误 i/o 超时

我编写了简单的服务器程序来从客户端接收数据。我有点不明白有时我从函数中得到错误readtcp4IP:PORTi/otimeoutint,err:=conn.Read([]byte)未超过函数SetDeadline()中设置的事件时间。我展示了我的部分代码,但我认为这就足够了。我接收数据的主循环如下。c:=NewClient()c.kickTime:time.Now()func(c*Client)Listen(){durationToClose:=time.Minute*time.Duration(5),c.conn.SetDeadline(c.kickTime.Add(c.durati

api - 如何使用 Golang 的 github.com/google/google-api-go-client/customsearch/v1

我已经完成了人们说不需要的Oauth回调,只需要cx代码,但我还没有弄清楚如何将cx参数添加到调用中。packagemainimport("fmt""log""github.com/vinniyo/authCallback""github.com/google/google-api-go-client/customsearch/v1")funcmain(){client,err:=authCallback.BuildOAuthHTTPClient()iferr!=nil{log.Fatalf("ErrorbuildingOAuthclient:%v",err)}service,err: